package com.yb.guigu.pick.security.bean;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/31 15:07
 * FileName: GuiguAbstractAutuenticationToken
 * Description:
 */
public class GuiguAbstractAuthenticationToken extends AbstractAuthenticationToken {

    private GuiguPickUser guiguPickUser;
    /**
     * Creates a token with the supplied array of authorities.
     *
     * @param authorities the collection of <tt>GrantedAuthority</tt>s for the principal
     *                    represented by this authentication object.
     */
    public GuiguAbstractAuthenticationToken(GuiguPickUser guiguPickUser, Collection<? extends GrantedAuthority> authorities) {

        super(authorities);

        this.guiguPickUser=guiguPickUser;

        super.setAuthenticated(true);
    }
    public GuiguAbstractAuthenticationToken(GuiguPickUser guiguPickUser) {
        super(null);
        this.guiguPickUser=guiguPickUser;
        super.setAuthenticated(false);
    }

    @Override
    public Object getCredentials() {
        return this.guiguPickUser.getPassword();
    }

    @Override
    public Object getPrincipal() {
        return this.guiguPickUser;
    }

    public GuiguPickUser getGuiguPickUser() {
        return guiguPickUser;
    }

    public void setGuiguPickUser(GuiguPickUser guiguPickUser) {
        this.guiguPickUser = guiguPickUser;
    }
}
